package main.gui.workspace;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;

public abstract class WorkspaceListItem extends JPanel implements ActionListener {

	protected JPanel thumbnailPanel;
	protected String guid;
	
	private ArrayList<JButton> optionButtons;
	
	public WorkspaceListItem(String[] buttonOptions, String guid) {
		super();
		
		this.guid = guid;
		this.setBorder(BorderFactory.createLineBorder(Color.YELLOW, 4));
		this.setBackground(Color.BLACK);
		
		this.setLayout(new BorderLayout());
		this.thumbnailPanel = new JPanel();
		this.add(thumbnailPanel, BorderLayout.CENTER);

		JPanel buttonPanel = new JPanel();
		buttonPanel.setLayout(new GridLayout(1, 3));
		this.optionButtons = new ArrayList<JButton>();
		for (String s : buttonOptions) {
			JButton b = new JButton(s);
			b.addActionListener(this);
			this.optionButtons.add(b);
			buttonPanel.add(b);
		}
		this.add(buttonPanel, BorderLayout.SOUTH);
	}

	public abstract void drawThumbnail();
	
	public abstract void buttonPressed(String buttonName);
	
	@Override
	public void actionPerformed(ActionEvent arg0) {
		JButton source = (JButton) arg0.getSource();
		this.buttonPressed(source.getText());
	}

}
